package com.docking.heylo.web.controller;

import com.docking.heylo.service.ICouponService;
import com.docking.heylo.web.dto.CouponDto;
import com.docking.heylo.web.utils.ResultUtil;
import com.docking.heylo.web.vo.BaseVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/***
 * 优惠券管理器
 */
@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private ICouponService couponService;

    /***
     * 创建优惠券
     *
     * @return
     */
    @RequestMapping("/produce")
    public BaseVo produce(@RequestBody CouponDto couponDto){
        couponService.produce(couponDto);
        return ResultUtil.success("优惠券创建成功");
    }

    /***
     * 优惠券列表
     *
     * @param couponDto
     * @return
     */
    @RequestMapping("/list")
    public BaseVo list(@RequestBody CouponDto couponDto){
        PageInfo<Map<String, Object>> list = couponService.list(couponDto);
        return ResultUtil.success("优惠券列表",list);
    }




}
